package month4.day28;

import java.io.*;
import java.util.LinkedList;
import java.util.Scanner;

public class S0 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = in.next();
        File file = new File("E:\\Java8\\新建文件夹\\baijiaxing.txt");
        LinkedList<String> list = new LinkedList<>();
        try {
            BufferedReader bfr = new BufferedReader(new InputStreamReader(new FileInputStream(file),"gbk"));
            String s1;
            while ((s1 = bfr.readLine()) != null) {
                list.add(s1);
            }
            bfr.close();
        } catch (Exception e) {
           throw new RuntimeException(e);
        }
        String s2 = name.substring(0, 2);
        String s3 = name.substring(0, 1);
        if (list.contains(s2))
            System.out.println(name + "姓" + s2);
        else if (list.contains(s3))
            System.out.println(name + "姓" + s3);
        else
            System.out.println("没有此姓");


    }
}
